package com.sweet.baolei.service;

import com.sweet.baolei.domain.User;
import com.sweet.baolei.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by jinxin on 2017/8/26.
 */
@Service
public class AdminService {

    @Autowired
    private UserMapper userMapper;

    public User select(Integer id){
       return userMapper.selectByPrimaryKey(id);
    }

    public void update1(String key) {
        String key1 =key;
        synchronized (key1){
            System.out.println(Thread.currentThread().getName());
            System.out.println(111111);
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public void update2(String key) {
        String key2 =key;
        synchronized (key2){
            System.out.println(Thread.currentThread().getName());
            System.out.println(222222);
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
